package com.fnzx.service.impl;

import com.alibaba.fastjson.JSON;
import com.fnzx.dao.EnterpriseUserDao;
import com.fnzx.entity.CooperativeUserEntity;
import com.fnzx.entity.EnterpriseUserEntity;
import com.fnzx.entity.UserEntity;
import com.fnzx.entity.vo.UserInfoVo;
import com.fnzx.service.EnterpriseUserService;
import com.fnzx.service.UserService;
import com.fnzx.util.PageUtils;
import com.fnzx.util.Query;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;



@Service("enterpriseUserService")
public class EnterpriseUserServiceImpl extends ServiceImpl<EnterpriseUserDao, EnterpriseUserEntity> implements EnterpriseUserService {
    @Autowired
    UserService userService;

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<EnterpriseUserEntity> page = this.page(
                new Query<EnterpriseUserEntity>().getPage(params),
                new QueryWrapper<EnterpriseUserEntity>()
        );
        List<UserInfoVo> collect = page.getRecords().stream().map(record -> {
            return userService.getUserInfoById(record.getId());
        }).collect(Collectors.toList());
        PageUtils pageUtils = new PageUtils(page);
        pageUtils.setList(collect);
        return pageUtils;
    }

}